region
A Rust library for dealing with memory regions.
It is implemented using platform specific APIs (e.g VirtualQuery
,
VirtualLock
, mprotect
, mlock
).
Documentation
Installation
Add this to your Cargo.toml
:
[]
= "0.0.9"
and this to your crate root:
extern crate region;
Example
- Cross-platform equivalents:
let ret5 = ;
// Page size
let pz = page_size;
// VirtualQuery | '/proc/self/maps'
let q = query?;
let qr = query_range?;
// VirtualProtect | mprotect
protect?;
// VirtualLock | mlock
let guard = lock?;
- Using a
View
(keeps track of pages previous protection):
// Assembly (x86) for returning an integer (5)
let ret5 = ;
let mut view = new.unwrap;
view.exec_with_prot.unwrap;
// The protection flags have been restored
assert_eq!;
Platforms
This library has (so far) support for Windows
, Linux
& macOS
.